#include "guidewidget.h"
#include "common.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QSpacerItem>
#include <QStackedWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QButtonGroup>
#include <QRadioButton>
#include <QCheckBox>
#include <QGroupBox>
#include <QComboBox>
#include <QListWidget>
#include <QFileDialog>
#include <QMessageBox>
#include <QScrollBar>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QHeaderView>
#include "nofocusdelegate.h"
#include "editwidget.h"
#include "mycombox.h"
#include <QTableWidget>
#include <QListWidget>



GuideWidget::GuideWidget(QDialog *parent)
    : QDialog(parent)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setFixedSize(800, 600);

    QFrame *frame_btn = new QFrame(this);
    frame_btn->setFixedSize(600, 60);
    btn_previous = new QPushButton(frame_btn);
    btn_next = new QPushButton(frame_btn);
    btn_cancel = new QPushButton(frame_btn);
    QHBoxLayout *layout_btn = new QHBoxLayout;
    layout_btn->addStretch();
    layout_btn->addWidget(btn_previous, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_btn->addWidget(btn_next, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_btn->addWidget(btn_cancel, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_btn->addSpacing(20);
    layout_btn->setContentsMargins(0, 0, 0, 0);
    frame_btn->setLayout(layout_btn);
    frame_btn->setGeometry(200, 540, 600, 60);

    QFrame *frame_guide = new QFrame(this);
    frame_guide->setFixedSize(200, 600);
    lab_one = new QLabel(frame_guide);
    lab_two = new QLabel(frame_guide);
    lab_all = new QLabel(frame_guide);
    lab_three = new QLabel(frame_guide);
    lab_four = new QLabel(frame_guide);
    lab_one->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    lab_two->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    lab_all->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    lab_three->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    lab_four->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    lab_one->setText("◆" + QObject::tr("Project Location"));
    lab_two->setText("◆" + QObject::tr("Select Type"));
    lab_all->setText("◆" + QObject::tr("All"));
    lab_three->setText("◆" + QObject::tr("Interval"));
    lab_four->setText("◆" + QObject::tr("Project File"));
    QFont f = lab_one->font();
    f.setPointSize(12);
    lab_one->setFont(f);
    lab_two->setFont(f);
    lab_all->setFont(f);
    lab_three->setFont(f);
    lab_four->setFont(f);

    QHBoxLayout *layout_one = new QHBoxLayout;
    layout_one->addWidget(lab_one, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_one->addStretch();
    layout_one->setContentsMargins(0, 0, 0, 0);

    QHBoxLayout *layout_two = new QHBoxLayout;
    layout_two->addWidget(lab_two, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_two->addStretch();
    layout_two->setContentsMargins(0, 0, 0, 0);

    QHBoxLayout *layout_all = new QHBoxLayout;
    layout_all->addWidget(lab_all, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_all->addStretch();
    layout_all->setContentsMargins(0, 0, 0, 0);

    QHBoxLayout *layout_three = new QHBoxLayout;
    layout_three->addWidget(lab_three, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_three->addStretch();
    layout_three->setContentsMargins(0, 0, 0, 0);

    QHBoxLayout *layout_four = new QHBoxLayout;
    layout_four->addWidget(lab_four, 0, Qt::AlignLeft | Qt::AlignVCenter);
    layout_four->addStretch();
    layout_four->setContentsMargins(0, 0, 0, 0);

    QVBoxLayout *layout_describe = new QVBoxLayout;
    layout_describe->addSpacing(30);
    layout_describe->addLayout(layout_one);
    layout_describe->addLayout(layout_two);
    layout_describe->addLayout(layout_all);
    layout_describe->addLayout(layout_three);
    layout_describe->addLayout(layout_four);
    layout_describe->addStretch();
    layout_describe->setContentsMargins(30, 0, 0, 0);

    frame_guide->setLayout(layout_describe);
    frame_guide->setGeometry(0, 0, 180, 600);

    set_widget = new QStackedWidget(this);
    set_widget->setFixedSize(600, 540);
    one_widget = new StepOne(set_widget);
    two_widget = new StepTwo(set_widget);
    all_widget = new StepAll(set_widget);
    three_widget = new StepThree(set_widget);
    four_widget = new StepFour(set_widget);
    set_widget->addWidget(one_widget);
    set_widget->addWidget(two_widget);
    set_widget->addWidget(all_widget);
    set_widget->addWidget(three_widget);
    set_widget->addWidget(four_widget);

    set_widget->setGeometry(180, 0, 600, 540);

    initStatus();
    btn_group = new QButtonGroup(this);
    btn_group->addButton(btn_previous, 0);
    btn_group->addButton(btn_next, 1);
    btn_group->addButton(btn_cancel, 2);

    connect(btn_group, SIGNAL(buttonClicked(int)), this, SLOT(SltBtnSub(int)));
    two_widget->checkbox_down->setChecked(true);
    two_widget->checkbox_mirror->setChecked(true);
}

void GuideWidget::SltBtnSub(int btn)
{
    switch (btn) {
        case 0:
            if(m_status == StatusFour && myapp::mDynamicMapParam->m_type == LCD)
               m_status -= 2;
            else
               m_status -= 1;

            UpdateStatus();
            set_widget->setCurrentIndex(m_status);
            break;

        case 1:

            if (!CheckValue()) return;

            if(m_status == StatusTwo && myapp::mDynamicMapParam->m_type == LCD)
               m_status += 2;
            else
               m_status += 1;

            UpdateStatus();
            set_widget->setCurrentIndex(m_status);
            if (m_status == StatusDone) accept();

            break;

        case 2:
            reject();
            break;

        default:
            break;
    }
}

void GuideWidget::initStatus()
{
    btn_previous->setVisible(false);

    btn_next->setText(QObject::tr("next"));
    btn_cancel->setText(QObject::tr("cancel"));

    lab_one->setStyleSheet("color:rgb(0, 0, 0);");

    lab_two->setStyleSheet("color:rgb(186, 189, 182);");

    lab_all->setStyleSheet("color:rgb(186, 189, 182);");

    lab_three->setStyleSheet("color:rgb(186, 189, 182);");

    lab_four->setStyleSheet("color:rgb(186, 189, 182);");

    set_widget->setCurrentIndex(0);
}

void GuideWidget::changeDescribe()
{
    switch (m_status) {
    case StatusOne:
        lab_one->setStyleSheet("color:rgb(0, 0, 0);");

        lab_two->setStyleSheet("color:rgb(186, 189, 182);");

        lab_all->setStyleSheet("color:rgb(186, 189, 182);");

        lab_three->setStyleSheet("color:rgb(186, 189, 182);");

        lab_four->setStyleSheet("color:rgb(186, 189, 182);");
        break;
    case StatusTwo:
        lab_one->setStyleSheet("color:rgb(186, 189, 182);");

        lab_two->setStyleSheet("color:rgb(0, 0, 0);");

        lab_all->setStyleSheet("color:rgb(186, 189, 182);");

        lab_three->setStyleSheet("color:rgb(186, 189, 182);");

        lab_four->setStyleSheet("color:rgb(186, 189, 182);");
        break;
    case StatusAll:
        lab_one->setStyleSheet("color:rgb(186, 189, 182);");

        lab_two->setStyleSheet("color:rgb(186, 189, 182);");

        lab_all->setStyleSheet("color:rgb(0, 0, 0);");

        lab_three->setStyleSheet("color:rgb(186, 189, 182);");

        lab_four->setStyleSheet("color:rgb(186, 189, 182);");
        break;
    case StatusThree:
        lab_one->setStyleSheet("color:rgb(186, 189, 182);");

        lab_two->setStyleSheet("color:rgb(186, 189, 182);");

        lab_all->setStyleSheet("color:rgb(186, 189, 182);");

        lab_three->setStyleSheet("color:rgb(0, 0, 0);");

        lab_four->setStyleSheet("color:rgb(186, 189, 182);");
        break;
    case StatusFour:
        lab_one->setStyleSheet("color:rgb(186, 189, 182);");

        lab_two->setStyleSheet("color:rgb(186, 189, 182);");

        lab_all->setStyleSheet("color:rgb(186, 189, 182);");

        lab_three->setStyleSheet("color:rgb(186, 189, 182);");

        lab_four->setStyleSheet("color:rgb(0, 0, 0);");
        break;
    default:
        break;
    }
}

void GuideWidget::UpdateStatus()
{
    if (m_status < StatusOne)
        m_status = StatusOne;

    if (m_status > StatusDone)
        m_status = StatusDone;

    if (m_status != StatusOne)
    {
        btn_previous->setText(QObject::tr("previous"));
        btn_previous->setVisible(true);
    }
    else
    {
        btn_previous->setVisible(false);
    }

    if (m_status < StatusFour)
    {
        btn_next->setText(QObject::tr("next"));
    }
    else
    {
       btn_next->setText(QObject::tr("finish"));
    }
    changeDescribe();
}

#include <QDirIterator>
bool GuideWidget::CheckValue()
{
    bool ret = true;
    switch (m_status) {
    //设置项目名称以及项目路径
    case StatusOne:
        if (one_widget->line_name->text().trimmed() == "" || one_widget->line_path->text().trimmed() == "")
        {
            QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("project name or path is empty!"));
            ret = false;
        }
        else if (!myapp::isDirExist(one_widget->line_path->text().trimmed()))
        {
            QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("the path you select is invalid!"));
            ret = false;
        }
        else
        {
            myapp::mDynamicMapParam->m_project_name = one_widget->line_name->text().trimmed();
            myapp::mDynamicMapParam->m_project_path = one_widget->line_path->text().trimmed();
        }
        break;

    case StatusTwo:
    {
        if (two_widget->radio_map->isChecked())
        {
            myapp::mDynamicMapParam->m_type = DRM;
            if (two_widget->line_width->text() != ""
                    && two_widget->line_height->text() != "")
            {
                //获取整体的宽高，首个点的起始位置
                myapp::mDynamicMapParam->m_width = two_widget->line_width->text().trimmed().toInt();
                myapp::mDynamicMapParam->m_height = two_widget->line_height->text().trimmed().toInt();

                if (two_widget->checkbox_mirror->checkState() == Qt::Checked)
                {
                    myapp::mDynamicMapParam->m_has_mirror = true;
                }
                else if (two_widget->checkbox_mirror->checkState() == Qt::Unchecked)
                {
                    myapp::mDynamicMapParam->m_has_mirror = false;
                }

                if (two_widget->checkbox_down->checkState() == Qt::Checked)
                {
                    myapp::mDynamicMapParam->m_has_down = true;
                }
                else if (two_widget->checkbox_down->checkState() == Qt::Unchecked)
                {
                    myapp::mDynamicMapParam->m_has_down = false;
                }

                if (two_widget->next_time->checkState() == Qt::Checked)
                {
                    myapp::mDynamicMapParam->m_next_time = true;
                }
                else if (two_widget->next_time->checkState() == Qt::Unchecked)
                {
                    myapp::mDynamicMapParam->m_next_time = false;
                }
            }
            else
            {
                 QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("width or height is empty!"));
                 ret = false;
            }
        }
        else if (two_widget->radio_lcd->isChecked())
        {
            myapp::mDynamicMapParam->m_type = LCD;
            if (two_widget->line_width->text() != ""
                                && two_widget->line_height->text() != "")
            {
                myapp::mDynamicMapParam->m_width = two_widget->line_width->text().trimmed().toInt();
                myapp::mDynamicMapParam->m_height = two_widget->line_height->text().trimmed().toInt();
                if (two_widget->checkbox_lcd_mirror->checkState() == Qt::Checked)
                {
                    myapp::mDynamicMapParam->m_has_mirror = true;
                }
                else if (two_widget->checkbox_lcd_mirror->checkState() == Qt::Unchecked)
                {
                    myapp::mDynamicMapParam->m_has_mirror = false;
                }
            }
            else
            {
                QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("width or height is empty!"));
                ret = false;
            }

            updateFile();
        }
    }
        break;

    case StatusAll:
    {
        myapp::mDynamicMapParam->mLineInfoVector.clear();

        int item_count = all_widget->list_line->count();

        for (int i = 0; i < item_count; i++)
        {
            LineInfo line_info;
            QListWidgetItem *item = all_widget->list_line->item(i);
            QWidget *widget = all_widget->list_line->itemWidget(item);
            LineSetWgt *line_wgt = dynamic_cast<LineSetWgt *>(widget);
            if (line_wgt)
            {
                if (line_wgt->line_station_num->text() != "" && line_wgt->line_begin_x->text() != "" &&
                    line_wgt->line_begin_y->text() != "" && line_wgt->line_end_x->text() != "" &&
                    line_wgt->line_end_y->text() != "")
                {
                    line_info.station_num = line_wgt->line_station_num->text().trimmed().toInt();
                    line_info.staggerd = line_wgt->combox_staggered->currentIndex();
                    line_info.begin_x = line_wgt->line_begin_x->text().trimmed().toInt();
                    line_info.begin_y = line_wgt->line_begin_y->text().trimmed().toInt();
                    line_info.end_x = line_wgt->line_end_x->text().trimmed().toInt();
                    line_info.end_y = line_wgt->line_end_y->text().trimmed().toInt();
                    line_info.name_offset = myapp::getNameOffsetFromString(line_wgt->line_name_offset->text().trimmed().toStdString());

                    myapp::mDynamicMapParam->mLineInfoVector.push_back(line_info);
                }
                else
                {
                    QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("station_num or begin or end is empty!"));
                    ret = false;
                }
            }
        }

        myapp::mDynamicMapParam->m_station_data.station_height = all_widget->line_name_height->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_station_data.station_width = all_widget->line_name_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_station_data.point_width = all_widget->line_point_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_station_data.point_height = all_widget->line_point_height->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_station_data.line_width = all_widget->line_line_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_station_data.line_height = all_widget->line_line_height->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_unequal_spacing_offset = all_widget->line_unequal_spacing_offset->text().trimmed().toInt();

//        LineInfo line_info;

//        myapp::mDynamicMapParam->m_station_total = all_widget->line_station_num->text().trimmed().toInt();
//        line_info.station_num = all_widget->line_station_num->text().trimmed().toInt();

//        if (all_widget->line_station_num->text().trimmed() != "")
//        {
////            myapp::mDynamicMapParam->m_staggered = all_widget->combox_staggered->currentIndex();
//            line_info.staggerd = all_widget->combox_staggered->currentIndex();
//            myapp::mDynamicMapParam->m_unequal_spacing_offset = all_widget->line_unequal_spacing_offset->text().trimmed().toInt();
////            line_info.unequal_spacing_offset = all_widget->line_unequal_spacing_offset->text().trimmed().toInt();
////            myapp::mDynamicMapParam->m_station_interval = all_widget->line_station_interval->text().trimmed().toInt();
////            myapp::mDynamicMapParam->m_begin_x = all_widget->line_x->text().trimmed().toInt();
////            myapp::mDynamicMapParam->m_begin_y = all_widget->line_y->text().trimmed().toInt();
//            line_info.begin_x = all_widget->line_x->text().trimmed().toInt();
//            line_info.begin_y = all_widget->line_y->text().trimmed().toInt();

//            myapp::mDynamicMapParam->m_station_data.station_height = all_widget->line_name_height->text().trimmed().toInt();
//            myapp::mDynamicMapParam->m_station_data.station_width = all_widget->line_name_width->text().trimmed().toInt();
//            myapp::mDynamicMapParam->m_station_data.point_width = all_widget->line_point_width->text().trimmed().toInt();
//            myapp::mDynamicMapParam->m_station_data.point_height = all_widget->line_point_height->text().trimmed().toInt();
//            myapp::mDynamicMapParam->m_station_data.line_width = all_widget->line_line_width->text().trimmed().toInt();
//            myapp::mDynamicMapParam->m_station_data.line_height = all_widget->line_line_height->text().trimmed().toInt();

//            myapp::mDynamicMapParam->mLineInfoList[1] = line_info;
//        }
//        else
//        {
//            QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("please set station number!"));
//            ret = false;
//        }
    }
        break;

    case StatusThree:
    {
        myapp::mDynamicMapParam->m_has_interval = three_widget->need_interval->checkState() == Qt::Checked ? true : false;

        if (!myapp::mDynamicMapParam->m_has_interval)
        {
            updateFile();
            break;
        }

        if (myapp::mDynamicMapParam->m_type == DRM)
        {
            if (three_widget->line_station_num->text().trimmed() == "" || three_widget->line_cur_location->text().trimmed() == "")
            {
               QMessageBox::warning(this, QObject::tr("waring"), QObject::tr("interval station number or current station location is empty!"));
               ret = false;
            }
        }

        myapp::mDynamicMapParam->m_interval_station_num = three_widget->line_station_num->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_cur_station_pos = three_widget->line_cur_location->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_staggered = three_widget->combox_staggered_interval->currentIndex();
        myapp::mDynamicMapParam->m_interval_begin_x = three_widget->line_begin_x->text().toInt();
        myapp::mDynamicMapParam->m_interval_begin_y = three_widget->line_begin_y->text().toInt();
        myapp::mDynamicMapParam->m_interval_end_x = three_widget->line_end_x->text().toInt();
        myapp::mDynamicMapParam->m_interval_end_y = three_widget->line_end_y->text().toInt();
        myapp::mDynamicMapParam->m_interval_unequal_spacing_offset = three_widget->line_unequal_spacing_offset->text().trimmed().toInt();
//        myapp::mDynamicMapParam->m_interval_station_interval = three_widget->line_station_interval->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_name_offset = three_widget->line_station_offset->text().trimmed().toInt();

        myapp::mDynamicMapParam->m_interval_station_data.station_height = three_widget->line_name_height->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_station_data.station_width = three_widget->line_name_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_station_data.point_width = three_widget->line_point_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_station_data.point_height = three_widget->line_point_height->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_station_data.line_width = three_widget->line_line_width->text().trimmed().toInt();
        myapp::mDynamicMapParam->m_interval_station_data.line_height = three_widget->line_line_height->text().trimmed().toInt();
        updateFile();
    }

        break;

    default:
        break;
    }
    return ret;
}

void GuideWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter(this);

    QPen pen(Qt::gray);
    painter.setPen(pen);
    painter.drawLine(QPoint(40, 540), QPoint(760, 540));
}

void GuideWidget::updateFile()
{
    four_widget->list_file->clear();
    QStringList filelist;
    filelist << "welcome.xml" << "emergency.xml";
    QString all_route_file_name;
    QString interval_route_file_name;
    QString arrive_file_name;

    if (myapp::mDynamicMapParam->m_type == DRM)
    {
       int runDir = myapp::mDynamicMapParam->m_has_down == true ? 2 : 1;

       for (int i = 1; i <= runDir; i++)
       {
           all_route_file_name.append("all");
           all_route_file_name.append("_" + QString::number(i));// 上下行
           all_route_file_name.append(".xml");
           filelist << all_route_file_name;
           all_route_file_name = "";

           if (myapp::mDynamicMapParam->m_has_mirror)
           {
               all_route_file_name.append("all");
               all_route_file_name.append("_" + QString::number(i));// 上下行
               all_route_file_name.append("_mirror");// 镜像
               all_route_file_name.append(".xml");
               filelist << all_route_file_name;
               all_route_file_name = "";
           }

           if (myapp::mDynamicMapParam->m_has_interval)
           {
               interval_route_file_name.append("interval");
               interval_route_file_name.append("_" + QString::number(i));// 上下行
               interval_route_file_name.append(".xml");
               filelist << interval_route_file_name;
               interval_route_file_name = "";
               if (myapp::mDynamicMapParam->m_has_mirror)
               {
                   interval_route_file_name.append("interval");
                   interval_route_file_name.append("_" + QString::number(i));// 上下行
                   interval_route_file_name.append("_mirror");// 镜像
                   interval_route_file_name.append(".xml");
                   filelist << interval_route_file_name;
                   interval_route_file_name = "";
               }
           }

           LOG_QDEBUG << "station_num:" << myapp::mDynamicMapParam->m_station_total;

           myapp::mDynamicMapParam->m_station_total = 0;
           foreach(LineInfo line, myapp::mDynamicMapParam->mLineInfoVector)
           {
                myapp::mDynamicMapParam->m_station_total += line.station_num;
           }

           LOG_QDEBUG << "station_num:" << myapp::mDynamicMapParam->m_station_total;

           arrive_file_name.append("arrive");
           arrive_file_name.append("_" + QString::number(i));
           arrive_file_name.append(".xml");
           filelist << arrive_file_name;
           arrive_file_name = "";

           if (myapp::mDynamicMapParam->m_has_mirror)
           {
               arrive_file_name.append("arrive");
               arrive_file_name.append("_" + QString::number(i));
               arrive_file_name.append("_mirror");
               arrive_file_name.append(".xml");
               filelist << arrive_file_name;
               arrive_file_name = "";
           }
       }
    }
    else if (myapp::mDynamicMapParam->m_type == LCD)
    {
        filelist << "station.xml";
        if (myapp::mDynamicMapParam->m_has_mirror)
        {
            filelist << "station_mirror.xml";
        }
    }
    myapp::mDynamicMapParam->mMapObjectShow.clear();

    for (auto it = filelist.begin(); it != filelist.end(); it++)
    {
        four_widget->addItem(*it);
    }
}

StepOne::StepOne(QWidget *parent)
    : QWidget(parent)
{
     setWindowFlags(Qt::FramelessWindowHint);
     setFixedSize(parent->size());
     lab_describe = new QLabel(this);
     QString str_describe = QString("<font style = 'color:black; font-size:26px; font-weight:bold;'>%1</font>"
                                    "<br/>"
                                    "<font style = 'color:gray; font-size:16px;'>%2</font>")
                                   .arg(QObject::tr("Project Location"))
                                   .arg(QObject::tr("this wizard generates a project where the name and path select"));
     lab_describe->setText(str_describe);
     lab_describe->setAlignment(Qt::AlignLeft | Qt::AlignTop);
     lab_describe->setGeometry(0, 30, 500, 200);

     lab_name = new QLabel(QObject::tr("name:"), this);
     lab_path = new QLabel(QObject::tr("path:"), this);
     QFont f = lab_name->font();
     f.setPointSize(16);
     lab_name->setFont(f);
     lab_path->setFont(f);

     line_name = new QLineEdit(this);
     line_path = new QLineEdit(this);
     line_name->setFixedSize(460, 40);
     line_path->setFixedSize(380, 40);
     line_name->setStyleSheet("QLineEdit:{"
                              "background:white;"
                              "border: 1px black;"
                              "color:black;}");
     line_path->setStyleSheet("QLineEdit:{"
                              "background:white;"
                              "border: 1px black;"
                              "color:black;}");
     btn_select = new QPushButton(QObject::tr("select"), this);
     btn_select->setFixedSize(60, 40);

     QGridLayout *layout = new QGridLayout;

     layout->addWidget(lab_name, 0, 0, 1, 1, Qt::AlignLeft | Qt::AlignVCenter);
     layout->addWidget(line_name, 0, 1, 1, 5, Qt::AlignLeft | Qt::AlignVCenter);
     layout->addWidget(lab_path, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignVCenter);
     layout->addWidget(line_path, 1, 1, 1, 4, Qt::AlignLeft | Qt::AlignVCenter);
     layout->addWidget(btn_select, 1, 5, 1, 1, Qt::AlignLeft | Qt::AlignVCenter);
     layout->setContentsMargins(0, 360, 0, 20);

     setLayout(layout);

     connect(btn_select, &QPushButton::clicked, this, &StepOne::setPath);

}

void StepOne::setPath(bool checked)
{
    Q_UNUSED(checked);
    QString path = QFileDialog::getExistingDirectory(this);
    if (path != "")
    {
        line_path->setText(path);
    }
}

StepTwo::StepTwo(QWidget *parent)
    : QWidget(parent)
{
     setWindowFlags(Qt::FramelessWindowHint);
     setFixedSize(parent->size());
     lab_describe = new QLabel(this);
     QString str_describe = QString("<font style = 'color:black; font-size:26px; font-weight:bold;'>%1</font>"
                                    "<br/>"
                                    "<font style = 'color:gray; font-size:16px;'>%2</font>")
                                   .arg(QObject::tr("Select Type"))
                                   .arg(QObject::tr("this select the type that need to create"));
     lab_describe->setText(str_describe);
     lab_describe->setAlignment(Qt::AlignLeft | Qt::AlignTop);
     lab_describe->setGeometry(0, 30, 500, 80);

     radio_map = new QRadioButton(QObject::tr("DRM"), this);
     radio_lcd = new QRadioButton(QObject::tr("LCD"), this);
     QFont f = radio_map->font();
     f.setPointSize(20);
     radio_map->setFont(f);
     radio_lcd->setFont(f);
     radio_map->setFixedSize(100, 30);
     radio_lcd->setFixedSize(100, 30);

     radio_map->setCheckable(true);
     radio_lcd->setCheckable(true);
     radio_map->setGeometry(0, 190, radio_map->width(), radio_map->height());
     radio_lcd->setGeometry(100, 190, radio_lcd->width(), radio_lcd->height());
     radio_map->setChecked(true);

     lab_width = new QLabel(QObject::tr("Width:"), this);
     lab_height = new QLabel(QObject::tr("Height:"), this);
     f.setPointSize(12);
     lab_width->setFont(f);
     lab_height->setFont(f);
     lab_width->setFixedSize(120, 30);
     lab_height->setFixedSize(120, 30);
     lab_width->setGeometry(0, 240, lab_width->width(), lab_width->height());
     lab_height->setGeometry(240, 240, lab_height->width(), lab_height->height());

     line_width = new QLineEdit(this);
     line_height = new QLineEdit(this);
     line_width->setFixedSize(120, 30);
     line_height->setFixedSize(120, 30);
     line_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_width->setGeometry(80, 240, 100, 30);
     line_height->setGeometry(320, 240, 100, 30);

     checkbox_mirror = new QCheckBox(this);
     checkbox_down = new QCheckBox(this);
     next_time = new QCheckBox(this);

     checkbox_mirror->setText(QObject::tr("Mirror"));
     checkbox_down->setText(QObject::tr("Down"));
     next_time->setText(QObject::tr("Next Time"));

     checkbox_mirror->setFocusPolicy(Qt::NoFocus);
     checkbox_down->setFocusPolicy(Qt::NoFocus);
     next_time->setFocusPolicy(Qt::NoFocus);

     checkbox_mirror->setFixedSize(120, 30);
     checkbox_down->setFixedSize(120, 30);
     next_time->setFixedSize(120, 30);

     checkbox_mirror->setFont(f);
     checkbox_down->setFont(f);
     next_time->setFont(f);

     checkbox_mirror->setGeometry(0, 285, checkbox_mirror->width(), checkbox_mirror->height());
     checkbox_down->setGeometry(160, 285, checkbox_down->width(), checkbox_down->height());
     next_time->setGeometry(305, 285, next_time->width(), next_time->height());

     checkbox_lcd_mirror = new QCheckBox(this);
     checkbox_lcd_mirror->setText(QObject::tr("Mirror"));
     checkbox_lcd_mirror->setFixedSize(120, 30);
     checkbox_lcd_mirror->setFont(f);
     checkbox_lcd_mirror->setGeometry(0, 285, checkbox_lcd_mirror->width(), checkbox_lcd_mirror->height());
     checkbox_lcd_mirror->setVisible(false);

     radio_map->installEventFilter(this);
     radio_lcd->installEventFilter(this);
}

LineSetWgt::LineSetWgt(int line_num, QWidget *parent)
    : QWidget(parent)
    , m_line_num(line_num)
{
     setWindowFlags(Qt::FramelessWindowHint);
     setFixedSize(560, 100);
     setFocusPolicy(Qt::NoFocus);

     group_line = new QGroupBox(this);
     group_line->setTitle(QObject::tr("line") + QString::number(m_line_num));
     QFont f = group_line->font();
     f.setPointSize(12);
     group_line->setFont(f);

     group_line->setFixedSize(558, 100);
     group_line->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
     group_line->setStyleSheet("QGroupBox {background:transparent;border:1px solid lightgray;margin-top: 26px;}"
                               "QGroupBox::title{background:transparent;subcontrol-origin: margin;subcontrol-position: top left;padding: 0 0px;color:gray;}");

     lab_station_num = new QLabel(QObject::tr("Station Number:"), group_line);
     lab_station_num->setFixedSize(60, 30);

     line_station_num = new QLineEdit(group_line);
     line_station_num->setFixedSize(60, 30);
     line_station_num->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");

     lab_begin_point= new QLabel(QObject::tr("Begin Point:"), group_line);//中轴线，即x坐标
     lab_begin_point->setFixedSize(90, 30);

     line_begin_x = new QLineEdit(group_line);
     line_begin_x->setFixedSize(60, 30);
     line_begin_x->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");

     line_begin_y = new QLineEdit(group_line);
     line_begin_y->setFixedSize(60, 30);
     line_begin_y->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");

     lab_end_point= new QLabel(QObject::tr("End Point:"), group_line);//中轴线，即x坐标
     lab_end_point->setFixedSize(90, 30);

     line_end_x = new QLineEdit(group_line);
     line_end_x->setFixedSize(60, 30);
     line_end_x->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");

     line_end_y = new QLineEdit(group_line);
     line_end_y->setFixedSize(60, 30);
     line_end_y->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");


     lab_staggered = new QLabel(QObject::tr("Staggered:"), group_line);
     lab_staggered->setFixedSize(90, 30);

     QStringList list;
     list<<QObject::tr("All Up")<<QObject::tr("All Down")<<QObject::tr("Odd Up")<<QObject::tr("Even Up");
     combox_staggered = new MyCombox(list, group_line);

     lab_name_offset = new QLabel(QObject::tr("Name Offset:"));
     lab_name_offset->setFixedSize(90, 30);

     line_name_offset = new QLineEdit(group_line);
     line_name_offset->setFixedSize(60, 30);
     line_name_offset->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");

     QHBoxLayout *h_layout = new QHBoxLayout;
     h_layout->addWidget(lab_begin_point, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout->addWidget(line_begin_x, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout->addWidget(line_begin_y, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout->addSpacing(20);
     h_layout->addWidget(lab_end_point, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout->addWidget(line_end_x, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout->addWidget(line_end_y, 0, Qt::AlignLeft | Qt::AlignVCenter);

     h_layout->addStretch();
     h_layout->setSpacing(10);

     QHBoxLayout *h_layout_2 = new QHBoxLayout;
     h_layout_2->addWidget(lab_station_num, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout_2->addWidget(line_station_num, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout_2->addSpacing(10);
     h_layout_2->addWidget(lab_staggered, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout_2->addWidget(combox_staggered, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout_2->addSpacing(10);
     h_layout_2->addWidget(lab_name_offset, 0, Qt::AlignLeft | Qt::AlignVCenter);
     h_layout_2->addWidget(line_name_offset, 0, Qt::AlignLeft | Qt::AlignVCenter);

     h_layout_2->addStretch();
     h_layout_2->setSpacing(10);
     h_layout_2->setContentsMargins(0, 0, 0, 0);

     QVBoxLayout *main_layout = new QVBoxLayout;
     main_layout->addLayout(h_layout);
     main_layout->addLayout(h_layout_2);
     main_layout->addStretch();
     main_layout->setContentsMargins(8, 0, 0, 0);
     group_line->setLayout(main_layout);
     group_line->setGeometry(0, 0, group_line->width(), group_line->height());
}

StepAll::StepAll(QWidget *parent)
    : QWidget(parent)
{
     setWindowFlags(Qt::FramelessWindowHint);
     setFixedSize(parent->size());
     setFocusPolicy(Qt::NoFocus);
     lab_describe = new QLabel(this);
     QString str_describe = QString("<font style = 'color:black; font-size:26px; font-weight:bold;'>%1</font>"
                                    "<br/>"
                                    "<font style = 'color:gray; font-size:12px;'>%2</font>")
                                   .arg(QObject::tr("All"))
                                   .arg(QObject::tr("注:默认只有直线1,如需添加直线，点击添加按钮、删除直线点击删除按钮。直线1不可删除"));
     lab_describe->setText(str_describe);
     lab_describe->setAlignment(Qt::AlignLeft | Qt::AlignTop);
     lab_describe->setGeometry(0, 30, 500, 80);

     btn_add = new QPushButton(QObject::tr("add line"), this);
     btn_add->setFixedSize(290, 30);
     btn_del = new QPushButton(QObject::tr("subtraction line"), this);
     btn_del->setFixedSize(290, 30);
     btn_add->setGeometry(0, 110, btn_add->width(), btn_add->height());
     btn_del->setGeometry(290, 110, btn_del->width(), btn_del->height());
     connect(btn_add, &QPushButton::clicked, this, &StepAll::add_item);
     connect(btn_del, &QPushButton::clicked, this, &StepAll::sub_item);

     list_line = new QListWidget(this);
     list_line->setFrameShape(QListView::NoFrame);
     list_line->setStyleSheet("background:transparent;");//#transparent
     list_line->setFixedSize(580, 220);
     list_line->setGeometry(0, 110, list_line->width(), list_line->height());
     list_line->setViewMode(QListView::ListMode);
     list_line->setFocusPolicy(Qt::NoFocus);
     list_line->horizontalScrollBar()->hide();

     list_line->setMouseTracking(false);

     QScrollBar  *bar = list_line->verticalScrollBar();
     bar->setStyleSheet("QScrollBar{background: transparent;  border:none;width:30px ;margin-top:0px;margin-bottom:0px ;}"
                  "QScrollBar::handle:vertical{background: #BBBBBB; border-radius:15px;min-height: 80px ;width:30px ;}"
                  "QScrollBar::sub-line:vertical{height:0px;subcontrol-position:top;subcontrol-origin:margin;}"
                  "QScrollBar::add-line:vertical{height:0px;subcontrol-position:bottom;subcontrol-origin:margin;}");
     list_line->setGeometry(0, 140, list_line->width(), list_line->height());

     QListWidgetItem *item = new QListWidgetItem(list_line);
     item->setFlags(item->flags() & ~Qt::ItemIsSelectable & ~Qt::ItemIsEnabled);
     LineSetWgt *line_wgt = new LineSetWgt(1, list_line);
     item->setSizeHint(QSize(580, 110));
     list_line->setItemWidget(item, line_wgt);

     //全线图站名宽度
     lab_name_width = new QLabel(QObject::tr("Name Width:"), this);//中轴线，即y坐标
     lab_name_width->setFixedSize(120, 30);
     lab_name_width->setGeometry(0, 360, lab_name_width->width(), lab_name_width->height());
     line_name_width = new QLineEdit(this);
     line_name_width->setFixedSize(120, 30);
     line_name_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_name_width->setGeometry(100, 360, line_name_width->width(), line_name_width->height());

     //站名高度
     lab_name_height = new QLabel(QObject::tr("Name Height:"), this);//中轴线，即y坐标
     lab_name_height->setFixedSize(120, 30);
     lab_name_height->setGeometry(240, 360, lab_name_height->width(), lab_name_height->height());
     line_name_height = new QLineEdit(this);
     line_name_height->setFixedSize(120, 30);
     line_name_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_name_height->setGeometry(340, 360, line_name_height->width(), line_name_height->height());

     //点宽度
     lab_point_width = new QLabel(QObject::tr("Point Width:"), this);//中轴线，即y坐标
     lab_point_width->setFixedSize(120, 30);
     lab_point_width->setGeometry(0, 400, lab_point_width->width(), lab_point_width->height());
     line_point_width = new QLineEdit(this);
     line_point_width->setFixedSize(120, 30);
     line_point_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_point_width->setGeometry(100, 400, line_point_width->width(), line_point_width->height());

     //点高度
     lab_point_height = new QLabel(QObject::tr("Point Height:"), this);//中轴线，即y坐标
     lab_point_height->setFixedSize(120, 30);
     lab_point_height->setGeometry(240, 400, lab_point_height->width(), lab_point_height->height());
     line_point_height = new QLineEdit(this);
     line_point_height->setFixedSize(120, 30);
     line_point_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_point_height->setGeometry(340, 400, line_point_height->width(), line_point_height->height());

     //线宽度
     lab_line_width = new QLabel(QObject::tr("Line Width:"), this);//中轴线，即y坐标
     lab_line_width->setFixedSize(120, 30);
     lab_line_width->setGeometry(0, 440, lab_line_width->width(), lab_line_width->height());
     line_line_width = new QLineEdit(this);
     line_line_width->setFixedSize(120, 30);
     line_line_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_line_width->setGeometry(100, 440, line_line_width->width(), line_line_width->height());

     //线高度
     lab_line_height = new QLabel(QObject::tr("Line Hight:"), this);//中轴线，即y坐标
     lab_line_height->setFixedSize(120, 30);
     lab_line_height->setGeometry(240, 440, lab_line_height->width(), lab_line_height->height());
     line_line_height = new QLineEdit(this);
     line_line_height->setFixedSize(120, 30);
     line_line_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_line_height->setGeometry(340, 440, line_line_height->width(), line_line_height->height());

     lab_unequal_spacing_offset = new QLabel(QObject::tr("Unequal Spacing Offset:"), this);
     lab_unequal_spacing_offset->setFixedSize(240, 30);
     lab_unequal_spacing_offset->setGeometry(0, 480, lab_unequal_spacing_offset->width(), lab_unequal_spacing_offset->height());

     line_unequal_spacing_offset = new QLineEdit(this);
     line_unequal_spacing_offset->setFixedSize(120, 30);
     line_unequal_spacing_offset->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
     line_unequal_spacing_offset->setGeometry(100, 480, line_unequal_spacing_offset->width(), line_unequal_spacing_offset->height());
}

void StepAll::add_item()
{
    int count = list_line->count();
    LOG_QDEBUG<<"----add_item---"<<count;

    QListWidgetItem *item = new QListWidgetItem(list_line);
    item->setFlags(item->flags() & ~Qt::ItemIsSelectable & ~Qt::ItemIsEnabled);
    LineSetWgt *line_wgt = new LineSetWgt(count + 1, list_line);
    item->setSizeHint(QSize(580, 110));
    line_wgt->setFocusPolicy(Qt::NoFocus);
    list_line->setItemWidget(item, line_wgt);
}

void StepAll::sub_item()
{
    int count = list_line->count();
    LOG_QDEBUG<<"----sub_item---"<<count;
    if (count < 2)
        return;

    QListWidgetItem *item = list_line->takeItem(count-1);

    QWidget *del_widget = list_line->itemWidget(item);

    LineSetWgt *line_wgt = dynamic_cast<LineSetWgt *>(del_widget);

    if (line_wgt)
    {
        LOG_QDEBUG<<"--------del-----"<<line_wgt;
        delete  line_wgt;
    }
}

bool StepTwo::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::FocusIn)
    {
        if (watched == radio_map)
        {
            checkbox_down->setVisible(true);
            checkbox_mirror->setVisible(true);
            checkbox_lcd_mirror->setVisible(false);
            next_time->setVisible(true);
        }
        else if (watched == radio_lcd)
        {
            checkbox_mirror->setVisible(false);
            checkbox_down->setVisible(false);
            next_time->setVisible(false);
            checkbox_lcd_mirror->setVisible(true);
        }
    }

    return QWidget::eventFilter(watched, event);
}

StepThree::StepThree(QWidget *parent)
    :QWidget(parent)
{
    setWindowFlags(Qt::FramelessWindowHint);
    setFixedSize(parent->size());

    lab_describe = new QLabel(this);
    QString str_describe = QString("<font style = 'color:black; font-size:26px; font-weight:bold;'>%1</font>"
                                   "<br/>"
                                   "<font style = 'color:gray; font-size:16px;'>%2</font>")
                                  .arg(QObject::tr("Interval"))
                                  .arg(QObject::tr("*************************************************************************************************"));
    lab_describe->setText(str_describe);
    lab_describe->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    lab_describe->setGeometry(0, 30, 500, 100);

    group_interval_route = new QGroupBox(this);
//    group_interval_route->setTitle(QObject::tr("Interval Route Map"));
    QFont f = group_interval_route->font();
    f.setPointSize(16);
    group_interval_route->setFont(f);

    group_interval_route->setFixedSize(520, 380);
    group_interval_route->setAlignment(Qt::AlignCenter);
    group_interval_route->setStyleSheet("QGroupBox {background:white;border:1px solid lightgray;margin-top: 28px;}"
                                        "QGroupBox::title{background:white;subcontrol-origin: margin;subcontrol-position: top center;padding: 0 0px;color:gray;}");

    group_interval_route->setGeometry(0, 145, group_interval_route->width(), group_interval_route->height());


    need_interval  = new QCheckBox(this);
    need_interval->setText(QObject::tr("Interval Route Map"));
    need_interval->setFixedSize(300, 30);
    need_interval->setFont(f);
    need_interval->setCheckState(Qt::Checked);
    need_interval->setGeometry(0, 140, need_interval->width(), need_interval->height());

    need_interval->installEventFilter(this);


    lab_begin_point= new QLabel(QObject::tr("Begin Point:"), group_interval_route);//中轴线，即y坐标
    lab_begin_point->setFixedSize(120, 30);
    lab_begin_point->setGeometry(10, 130, lab_begin_point->width(), lab_begin_point->height());

    line_begin_x = new QLineEdit(group_interval_route);
    line_begin_x->setFixedSize(120, 30);
    line_begin_x->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_begin_x->setGeometry(110, 130, line_begin_x->width(), line_begin_x->height());

    line_begin_y = new QLineEdit(group_interval_route);
    line_begin_y->setFixedSize(120, 30);
    line_begin_y->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_begin_y->setGeometry(260, 130, line_begin_y->width(), line_begin_y->height());

    lab_end_point= new QLabel(QObject::tr("End Point:"), group_interval_route);//中轴线，即y坐标
    lab_end_point->setFixedSize(120, 30);
    lab_end_point->setGeometry(10, 170, lab_end_point->width(), lab_end_point->height());

    line_end_x = new QLineEdit(group_interval_route);
    line_end_x->setFixedSize(120, 30);
    line_end_x->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_end_x->setGeometry(110, 170, line_end_x->width(), line_end_x->height());

    line_end_y = new QLineEdit(group_interval_route);
    line_end_y->setFixedSize(120, 30);
    line_end_y->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_end_y->setGeometry(260, 170, line_end_y->width(), line_end_y->height());

    //全线图站名宽度
    lab_name_width = new QLabel(QObject::tr("Name Width:"), group_interval_route);//中轴线，即y坐标
    lab_name_width->setFixedSize(120, 30);
    lab_name_width->setGeometry(10, 210, lab_name_width->width(), lab_name_width->height());
    line_name_width = new QLineEdit(group_interval_route);
    line_name_width->setFixedSize(120, 30);
    line_name_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_name_width->setGeometry(110, 210, line_name_width->width(), line_name_width->height());

    //站名高度
    lab_name_height = new QLabel(QObject::tr("Name Height:"), group_interval_route);//中轴线，即y坐标
    lab_name_height->setFixedSize(120, 30);
    lab_name_height->setGeometry(260, 210, lab_name_height->width(), lab_name_height->height());
    line_name_height = new QLineEdit(group_interval_route);
    line_name_height->setFixedSize(120, 30);
    line_name_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_name_height->setGeometry(360, 210, line_name_height->width(), line_name_height->height());

    //点宽度
    lab_point_width = new QLabel(QObject::tr("Point Width:"), group_interval_route);//中轴线，即y坐标
    lab_point_width->setFixedSize(120, 30);
    lab_point_width->setGeometry(10, 250, lab_point_width->width(), lab_point_width->height());
    line_point_width = new QLineEdit(group_interval_route);
    line_point_width->setFixedSize(120, 30);
    line_point_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_point_width->setGeometry(110, 250, line_point_width->width(), line_point_width->height());

    //点高度
    lab_point_height = new QLabel(QObject::tr("Point Height:"), group_interval_route);//中轴线，即y坐标
    lab_point_height->setFixedSize(120, 30);
    lab_point_height->setGeometry(260, 250, lab_point_height->width(), lab_point_height->height());
    line_point_height = new QLineEdit(group_interval_route);
    line_point_height->setFixedSize(120, 30);
    line_point_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_point_height->setGeometry(360, 250, line_point_height->width(), line_point_height->height());

    //线宽度
    lab_line_width = new QLabel(QObject::tr("Line Width:"), group_interval_route);//中轴线，即y坐标
    lab_line_width->setFixedSize(120, 30);
    lab_line_width->setGeometry(10, 290, lab_line_width->width(), lab_line_width->height());
    line_line_width = new QLineEdit(group_interval_route);
    line_line_width->setFixedSize(120, 30);
    line_line_width->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_line_width->setGeometry(110, 290, line_line_width->width(), line_line_width->height());

    //线高度
    lab_line_height = new QLabel(QObject::tr("Line Hight:"), group_interval_route);//中轴线，即y坐标
    lab_line_height->setFixedSize(120, 30);
    lab_line_height->setGeometry(260, 290, lab_line_height->width(), lab_line_height->height());
    line_line_height = new QLineEdit(group_interval_route);
    line_line_height->setFixedSize(120, 30);
    line_line_height->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_line_height->setGeometry(360, 290, line_line_height->width(), line_line_height->height());

    lab_unequal_spacing_offset = new QLabel(QObject::tr("Unequal Spacing Offset:"), group_interval_route);
    lab_unequal_spacing_offset->setFixedSize(240, 30);
    lab_unequal_spacing_offset->setGeometry(10, 330, lab_unequal_spacing_offset->width(), lab_unequal_spacing_offset->height());

    line_unequal_spacing_offset = new QLineEdit(group_interval_route);
    line_unequal_spacing_offset->setFixedSize(120, 30);
    line_unequal_spacing_offset->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_unequal_spacing_offset->setGeometry(110, 330, line_unequal_spacing_offset->width(), line_unequal_spacing_offset->height());

    lab_station_offset = new QLabel(QObject::tr("Name Offset:"), group_interval_route);
    lab_station_offset->setFixedSize(240, 30);
    lab_station_offset->setGeometry(260, 330, lab_station_offset->width(), lab_station_offset->height());

    line_station_offset = new QLineEdit(group_interval_route);
    line_station_offset->setFixedSize(120, 30);
    line_station_offset->setStyleSheet("QLineEdit:{background:white;border: 1px black;color:black;}");
    line_station_offset->setGeometry(360, 330, line_station_offset->width(), line_station_offset->height());

    lab_staggered = new QLabel(QObject::tr("staggered:"), group_interval_route);
    lab_staggered->setFixedSize(100, 30);
    lab_staggered->setGeometry(260, 90, lab_staggered->width(), lab_staggered->height());

    QStringList list;
    list<<QObject::tr("All Up")<<QObject::tr("All Down")<<QObject::tr("Odd Up")<<QObject::tr("Even Up");
    combox_staggered_interval = new MyCombox(list, group_interval_route);

//    combox_staggered_interval = new MyCombox(group_interval_route);
//    combox_staggered_interval->setFocusPolicy(Qt::NoFocus);
//    QPixmap pixmap(1, 30);
//    pixmap.fill(Qt::transparent);
//    QIcon icon(pixmap);
//    combox_staggered_interval->setIconSize(QSize(1, 30));
//    QStringList list;
    combox_staggered_interval->setGeometry(360, 90, combox_staggered_interval->width(), combox_staggered_interval->height());
//    list<<QObject::tr("All Up")<<QObject::tr("All Down")<<QObject::tr("Odd Up")<<QObject::tr("Even Up");
//    for (int i = 0; i<list.count(); i++)
//    {
//       combox_staggered_interval->addItem(icon, list.at(i));
//    }

    lab_station_num = new QLabel(QObject::tr("station num:"), group_interval_route);
    lab_station_num->setFixedSize(200, 30);
    line_station_num = new QLineEdit(group_interval_route);
    line_station_num->setFixedSize(100, 30);
    line_station_num->setStyleSheet("QLineEdit:{"
                                    "background:white;"
                                    "border: 1px black;"
                                    "color:black;}");
    lab_cur_location = new QLabel(QObject::tr("current location:"), group_interval_route);
    lab_cur_location->setFixedSize(200, 30);
    line_cur_location = new QLineEdit(group_interval_route);
    line_cur_location->setFixedSize(100, 30);
    line_cur_location->setStyleSheet("QLineEdit:{"
                                     "background:white;"
                                     "border: 1px black;"
                                     "color:black;}");
    lab_station_num->setGeometry(10, 50, lab_station_num->width(), lab_station_num->height());
    line_station_num->setGeometry(110, 50, line_station_num->width(), line_station_num->height());
    lab_cur_location->setGeometry(10, 90, lab_cur_location->width(), lab_cur_location->height());
    line_cur_location->setGeometry(110, 90, line_cur_location->width(), line_cur_location->height());

}

bool StepThree::eventFilter(QObject *watched, QEvent *event)
{
    if (watched == need_interval)
    {
        if (need_interval->checkState() == Qt::Checked)
        {
            group_interval_route->setVisible(true);
        }
        else if (need_interval->checkState() == Qt::Unchecked)
        {
            group_interval_route->setVisible(false);
        }

    }
    return QWidget::eventFilter(watched, event);
}

StepFour::StepFour(QWidget *parent)
    :QWidget(parent)
{
    setWindowFlags(Qt::FramelessWindowHint);
    setFixedSize(parent->size());

    lab_describe = new QLabel(this);
    QString str_describe = QString("<font style = 'color:black; font-size:26px; font-weight:bold;'>%1</font>")
                                  .arg(QObject::tr("Project File"));
    lab_describe->setText(str_describe);
    lab_describe->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    lab_describe->setGeometry(0, 30, 500, 200);

    list_file = new QListWidget(this);
    list_file->setFixedSize(500, 300);
    list_file->setGeometry(0, 230, 500, 300);

}

void StepFour::addItem(QString file_name)
{
    int row = list_file->count();
    list_file->insertItem(row, file_name);

    myapp::mDynamicMapParam->mMapObjectShow[file_name] = NULL;
}




